import { getOpenId } from "@/api/login.js"

export function wxLogin(){
	return new Promise((resolve, reject) => {
		login().then(code => {
			getOpenId({js_code: code}).then(res => {
				resolve(res)
			})
		})
	})
}

export function login(){
	return new Promise((resolve, reject) => {
		wx.login({
			success:function(params) {
				let code = params.code;
				if (code) {
					resolve(code)
				}else {
					reject()
				}
			}
		})
	})
}